//
//  WiteBoxTestDetailViewController.m
//  WiteBox
//
//  Created by John Blanco on 6/28/09.
//  Copyright 2009 Effective UI. All rights reserved.
//

#import "WiteBoxTestDetailViewController.h"

#import "TestRun.h"
#import "AssertionException.h"
#import "WiteBoxStyles.h"

@implementation WiteBoxTestDetailViewController

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	self.title = [NSString stringWithFormat:@"%@ v%@", [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleName"], [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleVersion"]];
	self.view.backgroundColor = [WiteBoxStyles backgroundColor];

	expectedPromptLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 300, 30)];
	expectedPromptLabel.font = [UIFont boldSystemFontOfSize:16];
	expectedPromptLabel.textColor = [WiteBoxStyles tableHeaderColor];
	expectedPromptLabel.backgroundColor = [UIColor clearColor];
	expectedPromptLabel.text = @"Expected Value";

	expectedLabel = [[UITextView alloc] initWithFrame:CGRectMake(25, 40, 285, 60)];
	expectedLabel.font = [UIFont systemFontOfSize:14];
	expectedLabel.textColor = [WiteBoxStyles greenCorrect];
	expectedLabel.backgroundColor = [UIColor clearColor];
	expectedLabel.editable = NO;
	expectedLabel.scrollEnabled = NO;

	actualPromptLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 30)];
	actualPromptLabel.font = [UIFont boldSystemFontOfSize:16];
	actualPromptLabel.textColor = [WiteBoxStyles tableHeaderColor];
	actualPromptLabel.backgroundColor = [UIColor clearColor];
	actualPromptLabel.text = @"Actual Value";
	
	actualLabel = [[UITextView alloc] initWithFrame:CGRectMake(25, 130, 285, 60)];
	actualLabel.font = [UIFont systemFontOfSize:14];
	actualLabel.textColor = [WiteBoxStyles redWrong];
	actualLabel.backgroundColor = [UIColor clearColor];
	actualLabel.editable = NO;
	actualLabel.scrollEnabled = NO;

	[self.view addSubview:expectedPromptLabel];
	[self.view addSubview:expectedLabel];
	[self.view addSubview:actualPromptLabel];
	[self.view addSubview:actualLabel];
}

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[testRun release];
	[expectedPromptLabel release];
	[expectedLabel release];
	[actualPromptLabel release];
	[actualLabel release];
    [super dealloc];
}

#pragma mark -

- (void)setTestRun:(TestRun *)value {
	[value retain];
	[testRun release];
	testRun = value;

	// set labels
	expectedLabel.text = [NSString stringWithFormat:@"%@\n", [testRun exceptionExpectedValue]];
	actualLabel.text = [NSString stringWithFormat:@"%@\n", [testRun exceptionActualValue]];
}

@end
